<?php

namespace app\shop\validate;

use app\shop\enums\payment\PayWay;

class RechargeValidate extends BaseValidate
{
    protected $rule = [
        'pay_way' => 'require|legality'
    ];

    protected $message = [
        'order_id.require' => '订单ID不能为空',
        'pay_way.require'  => '支付方式不能为空',
        'pay_way.legality' => '支付方式有误',
    ];

    protected $scene = [
        'recharge' => ['pay_way'],
    ];

    public function legality($value, $rule, $data): bool
    {
        return in_array($value, [PayWay::WXPAY, PayWay::ALIPAY]);
    }
}